package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.common.ValidStatusEnum;
import com.dt.platform.constants.enums.oa.AccountingRecordTypeEnum;
import com.dt.platform.constants.enums.oa.MeetingRoomStatusEnum;
import com.dt.platform.domain.oa.MeetingRoomPosition;
import com.dt.platform.domain.oa.meta.CrmCustomerReviewMeta;
import com.dt.platform.domain.oa.meta.FinAccountingRecordMeta;
import com.dt.platform.domain.oa.meta.MeetingRoomMeta;
import com.dt.platform.domain.oa.meta.MeetingRoomPositionMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.FinAccountingRecordPageController;
import com.dt.platform.proxy.oa.FinAccountingRecordServiceProxy;
import com.dt.platform.proxy.oa.MeetingRoomPositionServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;

public class FinAccountingRecordGtr extends BaseCodeGenerator {

//876476739826483200
    public FinAccountingRecordGtr() {
        super(OaTables.OA_FIN_ACCOUNTING_RECORD.$TABLE,"876475835756838912");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"operUser","operUser","operUser");
        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"payMethodDict","payMethodDict","payMethodDict");

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.ID).basic().hidden(true);



        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.AMOUNT).search().range();
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.RCD_TIME).search().range();
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.NAME).search();
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.NOTES).search();
        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_FIN_ACCOUNTING_RECORD.TYPE,
                        OaTables.OA_FIN_ACCOUNTING_RECORD.PAY_METHOD,
                        OaTables.OA_FIN_ACCOUNTING_RECORD.NAME,
                        OaTables.OA_FIN_ACCOUNTING_RECORD.NOTES,
                },

                new Object[]{
                        OaTables.OA_FIN_ACCOUNTING_RECORD.CREATE_TIME
                }
        );


        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);


        cfg.view().list().disableBatchDelete();

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.PAY_METHOD)
                .form().validate().required().form().selectBox().queryApi(DictItemServiceProxy.QUERY_LIST+"?dictCode=oa_accounting_pay_method")
                .paging(false).filter(false).toolbar(false)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(FinAccountingRecordMeta.PAY_METHOD_DICT).muliti(false);


        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.NAME).form().validate().required();

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.ACCOUNTING_CATEGORY).table().disable(true);

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.UPDATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.FILE_IDS).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.OPER_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.NOTES).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.NOTES).form().textArea().height(150);

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.OPER_ID).table().fillBy("operUser","name");
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.OPER_ID).form()
                .button().chooseEmployee(true);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.AMOUNT).form().validate().required().form().numberInput().defaultValue(0.0).scale(2);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.TYPE).form().validate().required().form().radioBox().enumType(AccountingRecordTypeEnum.class);
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.STATUS).form().radioBox().enumType(ValidStatusEnum.class);

        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.RCD_TIME).form().validate().required().form().dateInput().type(DatePickerType.datetime).defaultNow().format("yyyy-MM-dd HH:mm:ss").search().range();
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.OPER_TIME).form().dateInput().type(DatePickerType.datetime).defaultNow().format("yyyy-MM-dd HH:mm:ss").search().range();
        cfg.view().field(OaTables.OA_FIN_ACCOUNTING_RECORD.FILE_IDS).form().upload().acceptAllType().maxFileCount(3);
        //
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth);

        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_FIN_ACCOUNTING_RECORD.NAME,
                },
                new Object[] {
                        OaTables.OA_FIN_ACCOUNTING_RECORD.AMOUNT,
                }

        );
        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_FIN_ACCOUNTING_RECORD.TYPE,
                        OaTables.OA_FIN_ACCOUNTING_RECORD.PAY_METHOD,
                },
                new Object[] {
                        OaTables.OA_FIN_ACCOUNTING_RECORD.RCD_TIME
                }
        );

        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_FIN_ACCOUNTING_RECORD.FILE_IDS,
                        OaTables.OA_FIN_ACCOUNTING_RECORD.NOTES,
                }
        );


        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.COVER_EXISTS_FILE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        FinAccountingRecordGtr g=new FinAccountingRecordGtr();
        //生成代码
        g.generateCode();

      //g.generateMenu(FinAccountingRecordServiceProxy.class, FinAccountingRecordPageController.class);
    }

}
